package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JingfeiZhuanjia;
import com.ruoyi.system.service.IJingfeiZhuanjiaService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * jingfeizhuanjiaController
 * 
 * @author ruoyi
 * @date 2024-07-11
 */
@Controller
@RequestMapping("/system/jingfeizhuanjia")
public class JingfeiZhuanjiaController extends BaseController
{
    private String prefix = "system/jingfeizhuanjia";

    @Autowired
    private IJingfeiZhuanjiaService jingfeiZhuanjiaService;

    @RequiresPermissions("system:jingfeizhuanjia:view")
    @GetMapping()
    public String zhuanjia()
    {
        return prefix + "/zhuanjia";
    }

    /**
     * 查询jingfeizhuanjia列表
     */
    @RequiresPermissions("system:jingfeizhuanjia:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JingfeiZhuanjia jingfeiZhuanjia)
    {
        startPage();
        List<JingfeiZhuanjia> list = jingfeiZhuanjiaService.selectJingfeiZhuanjiaList(jingfeiZhuanjia);
        return getDataTable(list);
    }

    /**
     * 导出jingfeizhuanjia列表
     */
    @RequiresPermissions("system:jingfeizhuanjia:export")
    @Log(title = "jingfeizhuanjia", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JingfeiZhuanjia jingfeiZhuanjia)
    {
        List<JingfeiZhuanjia> list = jingfeiZhuanjiaService.selectJingfeiZhuanjiaList(jingfeiZhuanjia);
        ExcelUtil<JingfeiZhuanjia> util = new ExcelUtil<JingfeiZhuanjia>(JingfeiZhuanjia.class);
        return util.exportExcel(list, "jingfeizhuanjia数据");
    }

    /**
     * 新增jingfeizhuanjia
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存jingfeizhuanjia
     */
    @RequiresPermissions("system:jingfeizhuanjia:add")
    @Log(title = "jingfeizhuanjia", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JingfeiZhuanjia jingfeiZhuanjia)
    {
        return toAjax(jingfeiZhuanjiaService.insertJingfeiZhuanjia(jingfeiZhuanjia));
    }

    /**
     * 修改jingfeizhuanjia
     */
    @RequiresPermissions("system:jingfeizhuanjia:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        JingfeiZhuanjia jingfeiZhuanjia = jingfeiZhuanjiaService.selectJingfeiZhuanjiaById(id);
        mmap.put("jingfeiZhuanjia", jingfeiZhuanjia);
        return prefix + "/edit";
    }

    /**
     * 修改保存jingfeizhuanjia
     */
    @RequiresPermissions("system:jingfeizhuanjia:edit")
    @Log(title = "jingfeizhuanjia", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JingfeiZhuanjia jingfeiZhuanjia)
    {
        return toAjax(jingfeiZhuanjiaService.updateJingfeiZhuanjia(jingfeiZhuanjia));
    }

    /**
     * 删除jingfeizhuanjia
     */
    @RequiresPermissions("system:jingfeizhuanjia:remove")
    @Log(title = "jingfeizhuanjia", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jingfeiZhuanjiaService.deleteJingfeiZhuanjiaByIds(ids));
    }
}
